using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityUtilities;
/// <summary>
/// 上帝类，用于控制场景一些技能，比如控制下雨，随机刷出投掷物等
/// </summary>
public class god : MonoBehaviour
{
    public List<GameObject> skill;
    /// <summary>
    /// 随机生成的物品投掷范围
    /// </summary>
    public Transform leftRange;
    public Transform rightRange;
    public Transform topRange;
    /// <summary>
    /// 同时能够存在的物品最大数量
    /// </summary>
    public int maxItem = 1;
    /// <summary>
    /// 需要随机投放的物品
    /// </summary>
    public GameObject item;
    /// <summary>
    /// 随机投放物品间隔时间,单位s
    /// </summary>
    [SerializeField]
    public  CountdownPropertyLoop duration;
    void Awake()
    {
       
    }
    // Start is called before the first frame update
    void Start()
    {

    }

    // Update is called once per frame
    void Update()
    {
        if (duration.Progress())
        {
            
            
            if (GameObject.FindGameObjectsWithTag("item").Length < maxItem)
            {
                RangeFloat numberRange=new RangeFloat(leftRange.position.x, rightRange.position.x);
                Vector3 vector3 = new Vector3(numberRange.RandomInclusive, topRange.position.y, -1);
                Instantiate(item, vector3, new Quaternion(0, 0, 0,0));
            }
        }
    }
    public void restart()
    {
        Time.timeScale = 1;
        SceneManager.LoadScene("SampleScene");

    }

}
